package com.b2c.product.controller.platform;

import com.b2c.product.pojo.dto.SpecParamDto;
import com.b2c.product.pojo.entity.SpecParam;
import com.b2c.product.service.SpecParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import result.Result;

@RestController("platformSpecParamController")
@RequestMapping("/platform/spp")
public class SpecParamController {
    @Autowired
    private SpecParamService specParamService;

    /**
     * 通过品类id获取参数
     * @param spgId
     * @return
     */
    @GetMapping("/{spgId}")
    public Result getBySpgId(@PathVariable Integer spgId) {
        return specParamService.getBySpgId(spgId);
    }

    /**
     * 添加品类属性
     * @return
     */
    @PostMapping
    public Result insert(@RequestBody SpecParamDto specParamDto){
        return specParamService.insert(specParamDto);
    }

    /**
     * 删除属性
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id){
        return specParamService.delete(id);
    }

    /**
     * 修改属性
     * @param specParamDto
     * @param id
     * @return
     */
    @PutMapping("/{id}")
    public Result update(@RequestBody SpecParamDto specParamDto,Integer id){
        return specParamService.updateSpecParam(specParamDto,id);
    }

    /**
     * 通过sppId获取属性
     * @param sppId
     * @return
     */
    @GetMapping("/get/{sppId}")
    public Result getBySppId(@PathVariable Integer sppId){
        return specParamService.getBySppId(sppId);
    }
}
